package common

import (
	"common/configx"
	"fmt"
	"strings"
)

// ParseUri 拼接 minio 路径
func ParseUri(objectName string) string {
	objectName = strings.Trim(objectName, "/")
	if configx.C.Minio.UseProxy {
		//使用了代理转发
		return fmt.Sprintf("%s/%s", strings.Trim(configx.C.Minio.ProxyUrl, "/"), objectName)
	} else {
		var prefix = "http"
		if configx.C.Minio.UseSSL {
			prefix = "https"
		}
		return fmt.Sprintf("%s://%s/%s/%s", prefix, strings.Trim(configx.C.Minio.Endpoint, "/"), strings.Trim(configx.C.Minio.BucketName, "/"), objectName)
	}
}
